home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / appletalk / uab.shar / ddpport.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-12  |  4.2 KB  |  120 lines

  1. /*
  2.  * $Author: cck $ $Date: 88/09/14 10:19:06 $
  3.  * $Header: /src/local/mac/cap/etalk/RCS/ddpport.h,v 1.6 88/09/14 10:19:06 cck Rel $
  4.  * $Revision: 1.6 $
  5. */
  6.  
  7. /*
  8.  * ddpport.c - ddp port manager
  9.  *
  10.  * Handles the ddp port which sits on the interface boundary between
  11.  * DDP and LAP.  In addition, it carries the "local delivery" or
  12.  * demuxing information necessary to pass data to individual modules
  13.  *
  14.  *
  15.  * Copyright (c) 1988 by The Trustees of Columbia University 
  16.  *  in the City of New York.
  17.  *
  18.  * Permission is granted to any individual or institution to use,
  19.  * copy, or redistribute this software so long as it is not sold for
  20.  * profit, provided that this notice and the original copyright
  21.  * notices are retained.  Columbia University nor the author make no
  22.  * representations about the suitability of this software for any
  23.  * purpose.  It is provided "as is" without express or implied
  24.  * warranty.
  25.  *
  26.  *
  27.  * Edit History:
  28.  *
  29.  *  Sept 4, 1988  CCKim Created
  30.  *
  31. */
  32.  
  33. #ifndef _DDP_PORT_INCLUDED
  34. #define _DDP_PORT_INCLUDED "yes"
  35.  
  36. #include "mpxddp.h"
  37. #include "node.h"
  38.  
  39. /* this struct should really be hidden totally */
  40. /*
  41.  * PORT, struct port
  42.  *
  43.  * First, it describes the "lap" level parameters for a particular
  44.  * interface.  Second, it describes the ddp network attached to that
  45.  * interface.  ("lap" could be alap, elap, etc).
  46.  *
  47.  * Note: no routine should access port directly
  48.  *
  49. */
  50. typedef struct port {
  51.   struct port *p_next;        /* pointer to next struct */
  52.   int p_flags;            /* if any */
  53. #define PORT_ISCONNECTED 0x1
  54. /* could do at lower level, more efficient here? */
  55. #define PORT_WANTSLONGDDP 0x2    /* wants to output long ddp */
  56. #define PORT_NEEDSBROADCAST 0x4    /* needs broadcasts sent back */
  57. #define PORT_FULLRTMP 0x8    /* full rtmp (advertise bridge) */
  58. #define PORT_NETREADY 0x10    /* we know the net of the port */
  59. #define PORT_ISREADY 0x20    /* port info complete (net,node,zone) */
  60.   word p_ddp_net;        /* primary ddp network of port */
  61.   byte p_ddp_node;        /* primary ddp node of port */
  62.   byte *p_zonep;        /* remember our zone */
  63.   NODE *p_id;            /* lap level id */
  64.   caddr_t p_local_data;        /* local data for port manager */
  65.   int (*p_send_if)();        /* send routine for that port */
  66.   NODE *(*p_map_lap_if)();    /* ddp node to "lap" node mapper*/
  67.   int (*p_map_ddp_if)();    /* map "lap" node to ddp node */
  68.   /* other */
  69.   struct mpxddp_module *p_mpx;    /* remember demuxer */
  70.   int p_mpx_hdl;        /* mpx handle, in case for each port */
  71. } PORT;
  72.  
  73. /* PORT_T may change to an int */
  74. typedef struct port *PORT_T;
  75.  
  76. #define PORT_BAD(p) ((p) == NULL)
  77. #define PORT_GOOD(p) ((p) != NULL)
  78. #define PORT_NEXT(p) ((p)->p_next)
  79. #define PORT_LIST_START() ((PORT_T)port_list_start())
  80. #define PORT_FLAGS(p) ((p)->p_flags)
  81. /* port is open */
  82. # define PORT_CONNECTED(p) ((p)->p_flags & PORT_ISCONNECTED)
  83. /* network defined */
  84. # define PORT_READY(p) ((p)->p_flags & PORT_ISREADY)
  85. # define PORT_WANTS_LONG_DDP(p) ((p)->p_flags & PORT_WANTSLONGDDP)
  86. # define PORT_NEEDS_BROADCAST(p) ((p)->p_flags & PORT_NEEDSBROADCAST)
  87. # define PORT_ISBRIDGING(p) ((p)->p_flags & PORT_FULLRTMP)
  88. #define PORT_DDPNET(p) ((p)->p_ddp_net)
  89. #define PORT_DDPNODE(p) ((p)->p_ddp_node)
  90. #define PORT_GETLOCAL(p, type) ((type)(p)->p_local_data)
  91. #define PORT_NODEID(p) ((p)->p_id)
  92. /* send if possible */
  93. #define PORT_SEND(p,dst,laptype,hdr,hdrlen,data,datalen) \
  94.   (((p)->p_send_if) ? \
  95.   ((*(p)->p_send_if)((p),(dst),(laptype),(hdr),(hdrlen),(data),(datalen))) : \
  96.   -1)
  97. #define PORT_MAKENODE(p,net,node) \
  98.   (((p)->p_map_lap_if) ? \
  99.   ((*(p)->p_map_lap_if)((p),(net),(node))) : \
  100.   NULL)
  101. #define PORT_DEMUX(p, ddp, data, datalen) \
  102.   (((p)->p_mpx && (p)->p_mpx->mpx_send_ddp) ? \
  103.   ((*(p)->p_mpx->mpx_send_ddp)((p)->p_mpx_hdl, (ddp), (data), (datalen))) : \
  104.   -1)
  105. /* set the port demuxer */
  106. #define PORT_SETDEMUXER(p, desc) (port_setdemuxer((p), (desc)))
  107. #define PORT_NET_READY(p, net, sid) (port_net_ready((p),(net),(sid)))
  108. #define PORT_ZONE_KNOWN(p, zone) (port_zone_known((p),(zone)))
  109. #define PORT_GRAB(p, skt) (((p)->p_mpx && (p)->p_mpx->mpx_grab) ? \
  110.                ((*(p)->p_mpx->mpx_grab)(skt, NULL)) : -1)
  111. export PORT_T port_create();
  112. export boolean port_set_demuxer();
  113. export PORT_T port_list_start();
  114. export boolean port_net_ready();
  115. export boolean port_zone_known();
  116.  
  117. #endif /* INCLUDE THIS FILE */
  118.  
  119.  
  120.